home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_0799 / 401 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  3.6 KB

  1. Subject: O_APPEND, 2nd try...
  2. Date: Wed, 11 Aug 93 0:32:14 CES
  3. From: Juergen Lock <nox@jelal.north.de>
  4. Message-Id: <9308102232.AA00417@jelal.north.de>
  5.  
  6. Stephen Usher writes:
  7. > From oytix!olis.isc.north.de!arbi.informatik.uni-oldenburg.de!terminator.rs.itd.umich.edu!mint-request  Tue Aug 10 21:58:02 1993
  8. > From: Stephen Usher <steve@earth.ox.ac.uk>
  9. > Message-Id: <2653.9308100838@earth.ox.ac.uk>
  10. > Subject: Latest version of my init(8) package.
  11. > ...
  12.  
  13.  aah, so the list is still alive... :)  i haven't seen this back and
  14. also also got no answer, so i guess i got lost somehow:
  15.  
  16. ~From nox Fri Jul 30 00:23:14 1993
  17. ~Subject: Re: O_APPEND, file locking...
  18. ~To: schwab@ls5.informatik.uni-dortmund.de
  19. ~Date: Fri, 30 Jul 93 0:23:14 CES
  20. ~From: Juergen Lock <nox@jelal.north.de>
  21. ~Cc: mint@terminator.rs.itd.umich.edu
  22. ~In-Reply-To: <9307260845.AA11790@issan.informatik.uni-dortmund.de>; from "Andreas Schwab" at Jul 26, 93 10:45 am
  23. ~X-Mailer: ELM [version 2.3/ST PL11]
  24. ~Status: RO
  25.  
  26. Andreas Schwab writes:
  27.  
  28. > >>>>> On Fri, 23 Jul 93 20:35:44 CES, Juergen Lock <nox@jelal.north.de> said:
  29. > |>  quick question: on what filesystems does O_APPEND (or fopen (.. "a"))
  30. > |>  work with > 1 processes writing to the same file?  i doubt it does on
  31. > |>  GEMDOSfs, but on others?  reason i ask is should i put locking code
  32. > |>  around simple one-line fprintfs to logfiles.. i would rather not :-)
  33. > It works with every filesystem, because MiNT translates it to
  34. > lseek(SEEK_END) + write, atomically.
  35.  
  36.  well here's what i found out now.  seems it works with every
  37. filesystem except GEMDOS ones: (and i'm not surprised...)
  38.  
  39. -------cut----
  40. # touch foo
  41.     (file has to exist, see below)
  42. # cat >>foo
  43.  
  44. %1 +    49 Stopped              cat >> foo 
  45.     stop (^Z), foo is open now with O_APPEND...
  46. # echo 1 >>foo
  47.     appended 1 line
  48. # fg
  49. %1 +    49 Running              cat >> foo 
  50. 2
  51. 3
  52.     back to first process: append 2 more lines, then EOF (^D)
  53. # cat foo
  54. 2
  55. 3
  56.     where is line 1??
  57. # touch /f/foo
  58.     now the same thing on a minixfs...
  59. # cat >>/f/foo
  60.  
  61. %1 +    53 Stopped              cat >> /f/foo 
  62. # echo 1 >>/f/foo
  63. # fg
  64. %1 +    53 Running              cat >> /f/foo 
  65. 2
  66. 3
  67. # cat /f/foo
  68. 1
  69. 2
  70. 3
  71.     ok!
  72. # rm /f/foo
  73. # cat >>/f/foo
  74.     and now what happens when the file does not exist...
  75.  
  76. %1 +    56 Stopped              cat >> /f/foo 
  77. # echo 1 >>/f/foo
  78. /f/foo: cannot open
  79. # kill %1
  80. %1 +    56 Terminated           cat >> /f/foo 
  81. -------cut----
  82.  
  83.  conclusions :-)
  84.  
  85. 1. i think open should use Fopen not Fcreate on MiNT versions that
  86. have O_CREAT in the kernel, then O_APPEND and file sharing modes etc
  87. won't get lost.  (haven't tried but i think that was the reason for
  88. `cannot open'...)
  89.  
  90. 2. i'm quite sure what we have here is the old GEMDOS bug that it can't
  91. really cope with 2 opens to the same file, another one that nobody
  92. seems to believe me... (atleast it cant as soon as one starts writing.)
  93. this is MiNT 1.07 (with patches), and TOS 2.05.
  94.  
  95. 3. and here's the patch for ksh so it uses O_APPEND :-)
  96.  
  97. --- exec.c_3    Thu Jul  8 14:29:12 1993
  98. +++ exec.c    Wed Jul 28 19:06:12 1993
  99. @@ -856,11 +856,16 @@
  100.          break;
  101.  
  102.        case IOCAT:
  103. +#ifdef O_APPEND
  104. +        u = open(cp, O_WRONLY|O_CREAT|O_APPEND, 0666);
  105. +        break;
  106. +#else
  107.          if ((u = open(cp, 1)) >= 0) {
  108.              (void) lseek(u, (long)0, 2);
  109.              break;
  110.          }
  111.          /* FALLTHROUGH */
  112. +#endif
  113.        case IOWRITE:
  114.          u = creat(cp, 0666);
  115.          break;
  116.  
  117.  cheers,
  118.     Juergen
  119.  
  120. PS: are there TOS (GEMDOS) versions that have the bug fixed?  can't be
  121. before falcon TOS i assume...
  122.  
  123. PPS: now would _you_ prefer a shell where you don't have source? ;-)
  124. -- 
  125. J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
  126.                                 ...ohne Gewehr
  127. PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA 
  128.